<template>
  <div class="message-item" @click="goDetail">
      <div class="item-img-wrap">
          <div class="item-img" v-bind:style="{backgroundImage:'url('+thumb+')'}"></div>
      </div>
      <div class="item-content">
        <div class="item-name">{{name}}</div>
        <div class="item-desc">{{desc}}</div>
        <p class="item-time">{{time | date}}</p>
      </div>
      <div class="item-state">
            <div v-bind:class="{ item_state_pay : state }">{{state == true ? '已读' : '未读'}}</div>
      </div>
  </div>
</template>

<script>
export default {
  name: 'message-item',
  comments: 'message-item',
  props: {
    id: Number,
    thumb: {
      type: String,
      default: './static/images/消息.png'
    },
    name: String,
    desc: String,
    time: Number,
    state: Number
  },
  created () {
  },
  data () {
    return {
    }
  },
  methods: {
    goDetail: function () {
      this.$router.push({
        name: 'message_detail',
        params: {
          message_id: this.id
        }
      })
    }
  }
}
</script>
<style lang="postcss" scoped>
.message-item{
    background-color: #333;
    position: relative;
    border-bottom: 1px solid #fff;
    overflow: hidden;
    display: flex;
    justify-content: center;
    width: 100%;
    min-height: 60px;
}
.item-img-wrap{
    width: 20%;
    position: absolute;
    left: 0px;
    align-self: center;
    text-align: -webkit-center;
}
.item-img{
    height: 40px;
    width: 40px;
    border-radius: 50%;
    background-size: 100%;
}
.item-content{
    text-align: left;
    max-height: 100%;
    width: 50%;
    color: #f8f8f8;
    align-self: center;
    position: absolute;
    left: 20%;
}
.item-name{
    font-weight: bold;
}
.item-state{
    font-weight: bold;
    text-align: right;
    width: 20%;
    color: #f8f8f8;
    align-self: center;
    position: absolute;
    right: 3%;
}
.item-desc{
    font-size: 0.8rem;
    margin-top: 0px;
    color: #f8f8f8;
    overflow: hidden;
    text-overflow:ellipsis;
    white-space: nowrap;
}
.item-time{
    font-size: 0.8rem;
    margin: 0px;
    color: #f8f8f8;
}
.item-state>div{
    padding-right: 4px;
}
.item_state_pay{
    color:#fff;
}
</style>
